import Vue from 'vue'
import Router from 'vue-router'
// import HelloWorld from '@/components/HelloWorld'

Vue.use(Router)
import home from '../pages/home/home'
import order from '../pages/order/order'
import orderDetails from '../pages/order/details'
import orderInfo from '../pages/order/orderInfo'

import addmanagement from '../pages/management/addmanagement'
import statistics from '../pages/statistics'

import clients from '../pages/clients/main'
import cDetails from '../pages/clients/details'
import attributes from '../pages/document/atrribute'

import plist from '../pages/projectlist'
import plistDetails from '../pages/projectlist/details'

import alarm from '../pages/alarm'
// import alarmDetails from '../pages/alarm/lis'
// let routes = [
//   {
//       path: '/',
//       component: Home,
//       name: '导航一',
//       iconCls: 'el-icon-message',//图标样式class
//       children: [
//           //{ path: '/main', component: Main, name: '主页', hidden: true },
//           { path: '/table', component: Table, name: 'Table', meta: { keepAlive: false} },
//           { path: '/form', component: Form, name: 'Form', meta: { keepAlive: true}  },
//           { path: '/user', component: user, name: '列表' },
//       ]
//   }
// ]
const routes = [
  // {
  //   path: '',
  //   redirect: 'home'
  // },
  {
    path: '/home',
    // name: '首页（合同能源管理）',
    name: '首页',
    component: home,
    meta: {
      title: '首页',
      keepAlive: false
    }
  },
  {
    path: '/order',
    name: '任务管理',
    component: order,
    meta: {
      title: '任务管理'
    }
  },
  {
    path: '/order/details',
    name: '任务详情',
    component: orderDetails,
    meta: {
      title: '任务详情'
    }
  },
  {
    path: '/orderInfo',
    name: '报告详情',
    component: orderInfo,
    meta: {
      title: '报告详情',
      keepAlive: false
    },
  },
  {
    path: '/addmanagement',
    name: '新增设备',
    component: addmanagement,
    meta: {
      title: '新增设备',
      keepAlive: false
    },
  },
  {
    path: '/statistics',
    name: '项目统计',
    component: statistics,
    meta: {
      title: '项目统计',
      keepAlive: false
    },
  },
  {
    path: '/attributes',
    name: '参数列表',
    component: attributes,
    meta: {
      title: '参数列表',
      keepAlive: false
    },
  },
  {
    path: '/clients',
    name: '客户管理',
    component: clients,
    meta: {
      title: '客户管理',
      keepAlive: false
    },
  },
  {
    // 当 /user/:id/profile 匹配成功，
    // UserProfile 会被渲染在 User 的 <router-view> 中
    path: '/clients/details',
    name: '客户详情',
    component: cDetails,
    meta: {
      title: '客户详情',
      keepAlive: false
    },
  },
  {
    path: '/projectlist',
    name: '设备列表',
    component: plist,
    meta: {
      title: '设备列表',
      keepAlive: false
    },
  },
  {
    path: '/projectlist/details',
    name: '设备详情',
    component: plistDetails,
    meta: {
      title: '设备详情',
      keepAlive: false
    },
  },
  {
    path: '/alarm',
    name: '告警记录',
    component: plist,
    meta: {
      title: '告警记录',
      keepAlive: false
    },
  },
  // {
  //   path: '/alarm/details',
  //   name: '告警详情',
  //   component: plistDetails,
  //   meta: {
  //     title: '告警详情',
  //     keepAlive: false
  //   },
  // },
]

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export default new Router({
  routes,
  mode: 'history',
  base: '/work1/'
})
